package game;

/**
 * This interface describes the operations that a grid must provides.
 * 
 * @author nicolas
 */
public interface Grid {

	public static final char BLACK = '#';
	public static final char BLANK = ' ';
	
	/**
	 * This is the enumeration of the different directions to write words.
	 */
	public enum Direction {
		HORIZONTAL,
		VERTICAL
	}
	
	/**
	 * Get the number of columns in the grid.
	 * @return the # of columns
	 */
	public int getColsNCount();
	
	/**
	 * Get the number of rows in the grid.
	 * @return the # of rows
	 */
	public int getRowsCount();
	
	/**
	 * Write a word in a new returned grid.
	 * @param row the first letter row
	 * @param col the first letter column
	 * @param word the word to write
	 * @param direction the direction to write
	 * @return a new Grid object that have the word written in direction d at (row, col)
	 */
	public Grid write(int row, int col, String word, Direction direction);
	
	/**
	 * Turn to black a cell in a new returned grid.
	 * @param row the row of the cell to turn black
	 * @param col the column of the cell to turn black
	 * @return a new Grid object that have now a black cell at (row, col).
	 */
	public Grid writeBlack(int row, int col);
	
	/**
	 * This methods read a succession of character starting from (row, col)
	 * until the end of the grid or a non-letter cell in an given direction.
	 * @param row the row of the first letter
	 * @param col the column of the first letter
	 * @param direction the direction to read
	 * @return the string that is read from (row, col), null when empty or black
	 */
	public String getWord(int row, int col, Direction direction);
	
	/**
	 * Export the state of the grid to binary representation.
	 * @return the state of the grid
	 */
	public char[][] toState();
	
	/**
	 * Restore the state of the grid from a binary representation previously
	 * exported by the toState method.
	 * @param state 
	 */
	public void fromState(char[][] state);
	
	/**
	 * Provide a mean to know if the grid is full or not.
	 * @return true when there is no more blank in a grid.
	 */
	public boolean isFull();

	/**
	 * 
	 * @return
	 */
	public char[][] getState();
	
	/**
	 * 
	 * @return
	 */
	public Grid clone();
	
}
